{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ef304a21",
   "metadata": {},
   "source": [
    "#   [Py4Hw User Guide](../UserGuide.ipynb)> 1.7 Interfaces\n",
    "###  [Next: 1.7 Abstract Logic](../s01/abstract.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db239b6c",
   "metadata": {},
   "source": [
    "Interfaces are groups of wires semantically related.\n",
    "Interfaces are point to point (NOT POINT TO MULTIPOINT AS WIRES!)\n",
    "\n",
    "This is because Interfaces are bidirectional, so 1->n and n<-1 can only resolve into 1<--->1.\n",
    "\n",
    "Who is the source, and who is the sink generaly depends on what is the majority of wires going in which direction.\n",
    "\n",
    "Imagine we have an interface like this\n",
    "\n",
    "<pre>\n",
    "+----------+         +----------+\n",
    "|        A |-------->| A        |\n",
    "| Source B |-------->| B  Sink  |\n",
    "|        C |<--------| C        |\n",
    "+----------+         +----------+\n",
    "</pre>\n",
    "\n",
    "The Interface class maintains a list with the signals that go from source to sink (A and B) , and another list with the signals that go from sink to source (C).\n",
    "\n",
    "The Logic class has a method to add all the signals of the interface to the circuit, either as source or sink.\n",
    "\n",
    "When you create an interface you describe the signals participating in it, and save them in the class.\n",
    "\n",
    "Then the endpoints can connect to that interface either as source or sink."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "2372ad01",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVQAAADACAYAAABbEptUAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAeqUlEQVR4nO3deVxU9d4H8M+wDSCLgiAIBklSiqCooUYqCmK4JO6iJsrNbjfbbm491yzTcnvCJbXSVFBzSa8b8XAVdynLa4hKbomKCw6KoojsOL/nD+LkxAAzchwY+LxfL18vOHOW78z5+eHMmTPnqxBCCBARUY2Z1H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IlufEI1TjpeoRqsEAlIqrveNhFRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCQTBioRkUwYqEREMmGgEhHJhIFKRCST/wdrEsd6O0VZ3AAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 413x210 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import py4hw \n",
    "\n",
    "class Handshake(py4hw.Interface):\n",
    "    \n",
    "    def __init__(self, parent, name):\n",
    "        super().__init__(parent, name)\n",
    "        \n",
    "        self.A = self.addSourceToSink('A', 1)\n",
    "        self.B = self.addSourceToSink('B', 1)\n",
    "        self.C = self.addSinkToSource('C', 1)\n",
    "        \n",
    "        \n",
    "class Source(py4hw.Logic):\n",
    "    \n",
    "    def __init__(self, parent, name, port0):\n",
    "        super().__init__(parent, name)\n",
    "        \n",
    "        self.port0 = self.addInterfaceSource('src', port0)\n",
    "        \n",
    "        \n",
    "class Sink(py4hw.Logic):\n",
    "    \n",
    "    def __init__(self, parent, name, port0):\n",
    "        super().__init__(parent, name)\n",
    "        \n",
    "        self.port0 = self.addInterfaceSink('trg', port0)\n",
    "        \n",
    "sys = py4hw.HWSystem()\n",
    "\n",
    "port0 = Handshake(sys, 'port0')\n",
    "\n",
    "Source(sys, 'My Source', port0)\n",
    "Sink(sys, 'My Sink', port0)\n",
    "\n",
    "sch = py4hw.Schematic(sys)\n",
    "sch.draw()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "081d3165",
   "metadata": {},
   "source": [
    "Now we can have multiple instances in the same object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ea9b8e0d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgcAAAETCAYAAACiDqUrAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA2PUlEQVR4nO3deVwU9f8H8Ndy3yuHHCJBYogoKIqoUYKpkKE//eZ9FGqYR+ZV+rV8ZCZpWVKaZVkKqN/MDq28SrwjTUtFM69AxRQBUZT73s/vD2JyYoFdwF0XX8/Hw4fL7sxn3rv7ZnjN7OyMQgghQERERPQ3I30XQERERPcXhgMiIiKSYTggIiIiGYYDIiIikmE4ICIiIhmGAyIiIpJhOCAiIiIZhgMiIiKSYTggIiIiGYYDIjJIYWFhmDlzpsbTp6WlQaFQ4OTJk/esJtKfhIQEtGjRQqt5tO2hB0mzCQfjxo2DQqHA5MmTazw2depUKBQKjBs3rlHL2L9/P3r37g0HBwdYWVnhkUceQVRUFCoqKho1Lj142K91q6ysxFtvvQVfX19YWlrCwcEBPXr0QHx8vDTNli1bEBMTo8cqqdr90M8jRozAn3/+2ahl0D+aTTgAAA8PD2zatAnFxcXSfSUlJfjiiy/w0EMPNWrsM2fOoH///ujWrRt++uknnD59GitXroSpqSlUKlVjS69TeXn5PR2f9IP9WruFCxdi+fLliImJwdmzZ7F//35MnDgRt2/flqZxcHCAra1to5dFTUPf/WxpaQlnZ+dGLYf+0azCQZcuXfDQQw9hy5Yt0n1btmyBh4cHAgMDpfvWr18PR0dHlJaWyuYfMmQInn32WbVj7969G25ubnjnnXfQsWNHeHt748knn8SaNWtgZmYmTbd582Z06NAB5ubm8PLyQmxs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IiGYYDIiIikjHRdwFE98qtS+V13l/b4/dSRakKuemVULqbwMRcofPlU9NrbD/pow+J6qMQQgh9F0HUlG5fKceayEx9l0GklegdrrD3NNV3GUQAGA6ombp9pRxlhepb+9alcuyYl4PItx3g2Ea3K2PuOWh+mqKfzKwVDAZ0X+HHCtQsabKidWxjChc/Mx1UI+ceqPNFkg7oq5+I7gUekEhEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJMNwQERERDIMB0RERCTDcEBEREQyDAdEREQkw3BAREREMgwHREREJGOi7wKI9OXWpXJ9l9CkKkoFctMroHQ3hok5c7+uNLc+IgIYDugBZGatAADsmJej50qoOanuK6LmQCGEEPougkjXbl8pR1lh82p97jnQHzNrBew9TfVdBlGTYTggIiIiGW5eEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZEMwwERERHJMBwQERGRDMMBERERyTAcEBERkQzDAREREckwHBAREZHM/wPe/84JRWLe2QAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 645x318 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "class SourceSink(py4hw.Logic):\n",
    "    \n",
    "    def __init__(self, parent, name, port0, port1):\n",
    "        super().__init__(parent, name)\n",
    "        \n",
    "        self.port0 = self.addInterfaceSource('src', port0)\n",
    "        self.port1 = self.addInterfaceSink('trg', port1)\n",
    "        \n",
    "        \n",
    "sys = py4hw.HWSystem()\n",
    "\n",
    "port0 = Handshake(sys, 'channel1')\n",
    "port1 = Handshake(sys, 'channel2')\n",
    "\n",
    "Source(sys, 'My Source', port0)\n",
    "SourceSink(sys, 'My SourceSink', port1, port0)\n",
    "Sink(sys, 'My Sink', port1)\n",
    "\n",
    "sch = py4hw.Schematic(sys)\n",
    "sch.draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "48c9faff",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
